import axios from 'axios'
import config from '../config'

export function login(username, password, imageCode, keep) {
  return axios.post(config.SERVER_URL + window.apiPath + '/authenticate', {username, password, imageCode, rememberMe: keep, responseType: 'json'})
    .then(resp => resp.data)
}

export function getImageCode() {
  return axios.get(config.SERVER_URL + '/api/imageCode', {responseType: 'json'})
    .then(resp => resp)
}

export function applyUsers(username, password) {
  return axios.post(config.SERVER_URL + '/api/apply-users-login', {username, password, responseType: 'json'})
    .then(resp => resp)
}

export function getToken() {
  return axios.get(`/sys/auth/${config.appId}/${config.appSecret}`, {responseType: 'json'})
    .then(resp => resp)
}
